package controller;

import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.SimpleTagSupport;

import persistence.GruposDao;
import persistence.GruposDaoImpl;

public class AlunosTag extends SimpleTagSupport {

	@Override
	public void doTag() throws JspException, IOException {
		List<Integer> lista = new ArrayList<Integer>();
		GruposDao grDao = new GruposDaoImpl();
		try {
			lista = grDao.listaCodigosGrupos();
			JspWriter out = getJspContext().getOut();
			for (int l : lista) {
				StringBuffer linha = new StringBuffer();
				linha.append("<option value=\"");
				linha.append(l);
				linha.append("\">");
				linha.append(l);
				linha.append("</option>");
				out.println(linha.toString());
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

}
